package com.example.hospitalmanagement.activity

import android.content.Intent
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import androidx.recyclerview.widget.GridLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.example.hospitalmanagement.R
import com.example.hospitalmanagement.adapter.RegisterActivityAdapter
import com.example.hospitalmanagement.bean.DiagnosisAndTreatmentItem

/**
 * 价格公示Activity
 */
class PriceAnnouncementActivity : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_price_announcement)
        initView()
    }

    /**
     * 列表条目展示以及点击跳转
     */
    private fun initView() {
        val priceItem: RecyclerView = findViewById(R.id.price_announcement_item)
        priceItem.layoutManager = GridLayoutManager(this, 2)
        val dataList: MutableList<DiagnosisAndTreatmentItem> = mutableListOf(
            DiagnosisAndTreatmentItem(
                R.mipmap.price_announcement,
                "药品价格"
            ), DiagnosisAndTreatmentItem(
                R.mipmap.price_announcement,
                "收费项目"
            )
        )
        val adapter = RegisterActivityAdapter(this)
        adapter.dataList = dataList
        priceItem.adapter = adapter

        adapter.setListener {
            when (it) {
                0 -> {
                    startActivity(
                        Intent(
                            this@PriceAnnouncementActivity,
                            DrugPriceActivity::class.java
                        )
                    )
                }
                1 -> {
                    startActivity(
                        Intent(
                            this@PriceAnnouncementActivity,
                            ChargeItemActivity::class.java
                        )
                    )
                }
            }
        }
    }
}